package net.werup.am.collector.dao;

import java.util.List;

import net.werup.am.collector.domain.UnparsedXML;
import org.springframework.orm.jpa.support.JpaDaoSupport;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public class UnparsedXMLDaoImp extends JpaDaoSupport implements UnparsedXMLDao{

	public void delete(UnparsedXML unparsedXML) {
		getJpaTemplate().remove(unparsedXML);		
	}

	public UnparsedXML findById(long id) {
		return getJpaTemplate().find(UnparsedXML.class, id);
	}

	public List<UnparsedXML> findByName(String name) {
		return getJpaTemplate().find("select r from UnparsedXML r where r.name = ?1", name);
	}

	public List<UnparsedXML> findAll() {
		return getJpaTemplate().find("select r from UnparsedXML r ");
	}
	
	public void save(UnparsedXML unparsedXML) {
		getJpaTemplate().persist(unparsedXML);
		
	}

	public UnparsedXML update(UnparsedXML unparsedXML) {
		return getJpaTemplate().merge(unparsedXML);
	}

	public void flush() {
		getJpaTemplate().flush();
		
	}
}
